package com.example.arithmeticleetcode.leetcode.July;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors;

/**
 * @program: arithmetic-leetcode
 * @description:
 * @author: FangZhen
 * @create: 2020-07-03 09:18
 **/
public class Demo01 {

    public static void main(String[] args) throws Exception {

        A a = new A("真实姓名", "昵称", 20);
        String jsonString = JSON.toJSONString(a);
        System.out.println(jsonString); // {"real_name":"真实姓名","nick_name":"昵称","real_age":20}
        System.out.println(JSON.parseObject(jsonString, A.class));// A(name=真实姓名, nickName=昵称, age=20)
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        System.out.println(list);
        System.out.println(list.size());
        Collection<Integer> integers = Collections.unmodifiableCollection(list);
        integers.add(4);
        System.out.println(integers.size());


    }

//    public int[][] flipAndInvertImage(int[][] A) {
//
//    }
}

@Data
@AllArgsConstructor
@NoArgsConstructor
class A {


    @JSONField(ordinal = 0, name = "real_name")
    private String name;

    @JSONField(ordinal = 2, name = "nick_name")
    private String nickName;

    @JSONField(ordinal = 1, name = "real_age")
    private Integer age;
}
